package Frame.screen;

import FCRendering.FCRConstants;
import FCRendering.FCRMaster;
import FCRendering.ImageUtil;
import Function.Utils.SwingUtil;
import VWorldGameStudio.FCItem;

import java.awt.*;

import static FCRendering.FCRMaster.*;

public class ChuanZhenListScreen extends IScreen{

    Font font1;
    @Override
    public void dispatchPaintComponent(Graphics g, FCRMaster fcrMaster) {
        if(fcv.getShowChuanzhenNames().size() > 0){
            g.setFont(font1);
            int sX = (int)(835*fcv.getProportion());
            int sY = (int)((1080-fcv.getShowChuanzhenNames().size()*44)*fcv.getProportion()/2);
            g.drawImage(ImageUtil.getImage("gamebattlelisthead"), sX, sY,
                    (int) (250 * fcv.getProportion()), (int) (19 * fcv.getProportion()), this);
            int i = 0;
            int y1 = 0;
            for(i = 0;i< fcv.getShowChuanzhenNames().size(); i++) {
                g.setColor(Color.WHITE);
                y1 = (int) ((19+44*i)* fcv.getProportion()) + sY;
                g.drawImage(ImageUtil.getImage("gamebattlelistbody"),sX,
                        y1,(int) (250 * fcv.getProportion()), (int) (44 * fcv.getProportion()), this);
                String text = fcv.getShowChuanzhenNames().get(i);
                if(fcv.getMouseX() > sX && fcv.getMouseX() < sX+250 * fcv.getProportion()){
                    if(fcv.getMouseY() > y1 && fcv.getMouseY()<y1+44 * fcv.getProportion()) {
                        g.setColor(Color.BLUE);
                    }
                }
                int y = (int) (sY + 44* fcv.getProportion()/2 + SwingUtil.getStringHeight(text, font1));
                int x = (int)(sX + (250 * fcv.getProportion() - SwingUtil.getStringWidht(text, font1))/2);
                g.drawString(langLib.getNameOfId(text), x, (int) (44 * i * fcv.getProportion() + y));
            }
            g.drawImage(ImageUtil.getImage("gamebattlelistfoot"), sX,
                    (int) ((19 + 44 * i) * fcv.getProportion()) + sY, (int) (250 * fcv.getProportion()),
                    (int) (19 * fcv.getProportion()), this);
        }else if(fcv.getShowTankChuanzhenNames().size() > 0){
            g.setFont(font1);
            int sX = (int)(835*fcv.getProportion());
            int sY = (int)((1080-fcv.getShowTankChuanzhenNames().size()*44)*fcv.getProportion()/2);
            g.drawImage(ImageUtil.getImage("gamebattlelisthead"), sX, sY,
                    (int) (250 * fcv.getProportion()), (int) (19 * fcv.getProportion()), this);
            int i = 0;
            int y1 = 0;
            for(i = 0;i< fcv.getShowTankChuanzhenNames().size(); i++) {
                g.setColor(Color.WHITE);
                y1 = (int) ((19+44*i)* fcv.getProportion()) + sY;
                g.drawImage(ImageUtil.getImage("gamebattlelistbody"),sX,
                        y1,(int) (250 * fcv.getProportion()), (int) (44 * fcv.getProportion()), this);
                String text = fcv.getShowTankChuanzhenNames().get(i);
                if(fcv.getMouseX() > sX && fcv.getMouseX() < sX+250 * fcv.getProportion()){
                    if(fcv.getMouseY() > y1 && fcv.getMouseY()<y1+44 * fcv.getProportion()) {
                        g.setColor(Color.BLUE);
                    }
                }
                int y = (int) (sY + 44* fcv.getProportion()/2 + SwingUtil.getStringHeight(text, font1));
                int x = (int)(sX + (250 * fcv.getProportion() - SwingUtil.getStringWidht(text, font1))/2);
                g.drawString(langLib.getNameOfId(text), x, (int) (44 * i * fcv.getProportion() + y));
            }
            g.drawImage(ImageUtil.getImage("gamebattlelistfoot"), sX,
                    (int) ((19 + 44 * i) * fcv.getProportion()) + sY, (int) (250 * fcv.getProportion()),
                    (int) (19 * fcv.getProportion()), this);
        }
    }

    @Override
    protected void setBounds() {
        font1 = new Font(FCRConstants.FONT_BLACK, 0, (int) (24 * fcv.getProportion()));
    }
}
